import { EnumSchema } from '@/utils/common/types';
import { PresetColorEnum } from '@/enums/colorEnum';
import { useI18n } from '@/hooks/web/useI18n';

/** 用户标记枚举 */
export enum UserFlagEnum {
  /** 当前用户标识 */
  CurrentToken = '@CurrentUserId',
}

/** 用户标记实体 */
export class UserFlagEntity {
  /** 用户标记 */
  UserFlag: UserFlagEnum;
  /** 显示描述 */
  Display: string;
  /** 颜色 */
  Color?: PresetColorEnum | string;

  constructor(userFlag: UserFlagEnum, color?: PresetColorEnum | string) {
    const { t } = useI18n();
    this.UserFlag = userFlag;
    this.Color = color;
    switch (userFlag) {
      case UserFlagEnum.CurrentToken:
        // this.Display = '@当前用户';
        this.Display = `@${t('enum.userFlag.currentToken')}`;
        this.Color = this.Color ? this.Color : PresetColorEnum.Green;
        break;
    }
  }
}

//#region 获取用户标记枚举架构
/**
 * 获取用户标记枚举架构
 */
export function getUserFlagEnumSchema(enableTag = true): EnumSchema[] {
  const enumSchema: EnumSchema[] = [];
  const entities: UserFlagEntity[] = [new UserFlagEntity(UserFlagEnum.CurrentToken)];
  entities.forEach((item) => {
    enumSchema.push({
      key: item.UserFlag as string,
      label: item.Display as string,
      value: item.UserFlag as string,
      tag: enableTag,
      tagColor: item.Color,
    });
  });
  return enumSchema;
}
//#endregion
